#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;

const ll N = 1e6 + 10, INF = 0x3f3f3f3f;

ll n, n2, cnt[3];
string s;
ll sum[N << 1][3];

ll at(char a, char b)
{
    if (a == '0' && b == '0') return 0;
    if (a == '1' && b == '1') return 2;
    return 1;
}

bool check(ll l, ll r)
{
    for (ll i = 0;i <= 2;i++)
        if (sum[r][i] - sum[l - 1][i] > cnt[i]) return 0;
    return 1;
}

ll f(string& t)
{
    t = " " + s + s;
    for (ll i = 2;i <= n2;i += 2) {
        for (ll j = 0;j <= 2;j++) sum[i][j] = sum[i - 2][j];
        sum[i][at(t[i - 1], t[i])]++;
    }

    ll res = 0;
    ll l = 1, r = 0;
    while (l <= n2 && r <= n2) {
        while (r + 2 <= n2 && r - l + 3 <= n && check(l, r + 2))
            r += 2;
        res = max(res, r - l + 1);
        l += 2;
        r = max(r, l - 1);
    }
    return res;
}

void solve()
{
    cin >> cnt[0] >> cnt[1] >> cnt[2];
    cin >> s;n = s.size(); n2 = n * 2;

    ll ans = 0;
    string t = " " + s + s;
    ans = max(ans, f(t));

    s = s.back() + s;s.pop_back();
    t = " " + s + s;
    ans = max(ans, f(t));
    cout << ans << '\n';
}

signed main()
{
    //ios::sync_with_stdio(0);
    //cin.tie(0);cout.tie(0);
#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
    std::istringstream in(R"()");
    std::cin.rdbuf(in.rdbuf());
#endif
    ll T = 1;
    //cin>>T;
    for (ll i = 1;i <= T;i++) {
        solve();
    }
}